package prova.daos;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.management.RuntimeErrorException;



import prova.model.Prova;
import prova.util.Conexao;
import prova.controllers.CtrlProva;

public class DaoProva {
//	DESIGN PATTERNS - GANG OF FOUR...   SINGLETON, DATA ACCESS OBJECT (DAO) , FACTORY, FACADE, VO, BO...
	
	static String srtSQL = "";
	private static Connection connection;
	
	//Metodo Construtor
		public DaoProva(){					
			this.connection = Conexao.getConnection();
		}
		
	
	public void salvar(Prova prova){
		String sql = "insert into avaliacao(nome,sexo, curso, senha, perfil, acesso) value(?,?,?,?,?,?)";
		try{
			PreparedStatement stmt = connection.prepareStatement(sql);
			stmt.setString(1, prova.getNome());
			stmt.setString(2, prova.getSexo());
			stmt.setString(3, prova.getCurso());
			stmt.setString(4, prova.getSenha());
			stmt.setString(5, prova.getPerfil());
			stmt.setString(6, prova.getAcesso());
			stmt.execute();
			stmt.close();						
		}catch (SQLException e){
			throw new RuntimeException(e);			
		}
	}

}
